from die import Die
import plotly.express as px
die1=Die()
die2=Die()
results=[]
for roll_num in range(50000):
    result=die1.roll()+die2.roll()
    results.append(result)

#分析结果
frequencies=[]
poss_results=range(2,die1.num_sides+die2.num_sides)
for value in poss_results:
    frequency =results.count(value)
    frequencies.append(frequency)
#设置标题和标签
title ="Results of Rolling Two D6 1,000 Times"
Lables={"x":"Result","y":"Frequency of Result"}
fig=px.bar(x=poss_results,y=frequencies,title=title,labels=Lables)
fig.update_layout(xaxis_dtick=1)#使得每个都有标签
fig.write_html("dice_visual.html")#保存html网页
